<template>
    <el-dialog
      :title="title"
      :visible.sync="openDlg"
      width="500px"
      append-to-body
      destroy-on-close
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="审核结果" prop="applyExamType">
                <el-radio-group v-model="form.applyExamType">
                    <el-radio :label="2">通过</el-radio>
                    <el-radio :label="4">不通过</el-radio>
                </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="form.applyExamType == 4">
            <el-form-item label="不通过原因" prop="examRemark">
                <el-input v-model.trim="form.examRemark" placeholder="请输入不通过原因" />
            </el-form-item>
          </el-col>
          
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="openDlg = false">取 消</el-button>
      </div>
    </el-dialog>
</template>

<script>
 import { 
  poorStudentApply
  } from "@/api/poorStudent-scholarship/user.js";
export default {
    name:"auditDlg",
    props:{
      
    },
    data () {
        return {
            title: '审核',
            openDlg: false,
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                applyExamType: [
                  { required: true, message: '请选择审核结果', trigger: 'change' }
                ],
                examRemark: [
                  { required: true, message: '请输入不通过原因', trigger: 'blur' }
                ]
            }
        }
    },
    methods:{
        open (row) {
          this.form = {
            ...row,
            applyExamType: 2,
            examRemark: ''
          }
          this.openDlg = true
        },
        submitForm () {
          this.$refs["form"].validate((valid) => {
            if (valid) {
              poorStudentApply({
                id: this.form.id,
                applyExamType: this.form.applyExamType,
                examRemark: this.form.examRemark
              }).then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.openDlg = false;
                this.$emit("onSearch")
              });
            }
          });
        },
    }
}
</script>

<style lang="scss" scoped>

</style>